package com.biz.primus.base.enums;


import com.biz.primus.common.enums.EnumerableNameAndValueAndDescription;
import com.biz.primus.common.enums.converter.BaseEnumNameAndValueAndDescriptionConverter;
import java.util.Objects;

/**
 * @author zhangcheng
 * @date 2016/12/16
 * @reviewer
 * @see
 */
public enum CommonStatus implements EnumerableNameAndValueAndDescription {
    ENABLE("启用", 1),

    DISABLE("禁用", 2);

    private int value;

    private String name;

    CommonStatus(String name, int value) {
        this.value = value;
        this.name = name;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public int getValue() {
        return this.value;
    }

    @Override
    public String getDescription() {
        return name;
    }

    public static CommonStatus toggle(CommonStatus commonStatus) {
        if (Objects.isNull(commonStatus)) {
            return null;
        }
        return commonStatus == CommonStatus.ENABLE ? CommonStatus.DISABLE : CommonStatus.ENABLE;
    }

    public boolean isEnable() {
        return this == ENABLE;
    }

    public static class Converter extends BaseEnumNameAndValueAndDescriptionConverter<CommonStatus> {
    }
}
